<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{position: relative;}
        div{width: 200px;height: 200px;background-color: red;}
        span{
            position: absolute;
            top: 10px;
            left: 10px;
        }
    </style>
    <script>
        window.onload  = function(){
            var div = document.querySelector("div");
            var span =document.querySelector("span");
            div.onmousemove= function(e){//浏览器传过来参数  事件对象
                //获取鼠标位置
                // console.log(e);
                // console.log(e.x,e.y);
                span.style.top=e.y-4+"px";
                span.style.left=e.x-40+"px";


            }



        }
    </script>
</head>
<body>
    <div></div>
    <span>这是一段文字</span>
    <!-- leaber -->
</body>
</html>